<!DOCTYPE html>
<html class="Content">
<head>
    <title>xUnit.js: The WSH Engine</title>
    <link type="text/css" rel="Stylesheet" href="../Style/documentation.css" />
</head>
<body>
    <h1>The WSH Engine</h1>
    <p>
        The <a href="http://en.wikipedia.org/wiki/Windows_Script_Host">Windows Script Host</a> engine is installed by default in Windows versions since Windows '98. 
        By default, when running .js files it uses the <a href="http://en.wikipedia.org/wiki/JScript">JScript</a> engine, at the version currently patched by the Windows Update system.
    </p>
    <p>
        This is the engine that is used in IE5-IE8. To simulate a version of the engine based on a browser, you can use a VM upgraded to the version of IE that you are targeting.
    </p>
    <p>
        Since IE9, Internet Explorer uses the <a href="http://en.wikipedia.org/wiki/Chakra_(JScript_engine)">Chakra</a> engine instead. To tell the Windows Script Host to use this 
        engine instead of the JScript engine can be accomplished in one of two ways.
    </p>
    <p>
        First off, we need the CLSID for the Chakra engine:
        <span class="Code">
{16d51579-a30b-4c8b-a276-0ff4dc41e755}
        </span>
    </p>
    <p>
        Then, to use the Chakra engine only temporarily, you can specify the //E (engine) parameter:
        <span class="Code">
cscript.exe  //E:{16d51579-a30b-4c8b-a276-0ff4dc41e755}        
        </span>
    </p>
    <p>
        For a more permanent solution, you can modify the registry to include and specify a ProgID for Chakra:
        <span class="Code">
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{16d51579-a30b-4c8b-a276-0ff4dc41e755}\ProgID]
@="Chakra"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Wow6432Node\CLSID\{16d51579-a30b-4c8b-a276-0ff4dc41e755}\ProgID]
@="Chakra"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Chakra]
@="JScript Language"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Chakra\CLSID]
@="{16d51579-a30b-4c8b-a276-0ff4dc41e755}"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Chakra\OLEScript]
        </span>
    </p>
</body>
</html>